//
//  ByShopSearchVC.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/11/1.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByShopSearchVC.h"

// view
#import "ByViewSearchPartScroll.h"
#import "ByViewSearchProductListTable.h"

@interface ByShopSearchVC ()

@property (nonatomic, strong) ByViewSearchPartScroll *partScroll;
@property (nonatomic, strong) ByViewSearchProductListTable *listScroll;


@end

@implementation ByShopSearchVC

#pragma mark - view method
- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"商城";
    
    [self addLeftBackBarButtonItem];
    
    [self createViews];
}

#pragma mark - 创建视图
- (void)createViews {
    
    // 搜索栏
    UISearchBar *searchBar = [UISearchBar new];
    searchBar.searchBarStyle = UISearchBarStyleMinimal;
    searchBar.placeholder = @"搜索商品";
    [self.view addSubview:searchBar];
    [searchBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(@0);
        make.height.equalTo(@50);
    }];
    
    // 分类视图
    _partScroll = [[ByViewSearchPartScroll alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    _partScroll.titles = @[@"男装", @"女装", @"美食", @"电器", @"家具", @"母婴", @"水果", @"运动"];
    [self.view addSubview:_partScroll];
    [_partScroll mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.top.equalTo(searchBar.mas_bottom);
        make.width.equalTo(@80);
        if (@available(ios 11.0,*)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        } else {
            make.bottom.equalTo(@0);
        }
    }];
    
    // 列表
    _listScroll = [[ByViewSearchProductListTable alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    [self.view addSubview:_listScroll];
    [_listScroll mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_partScroll.mas_right);
        make.top.bottom.equalTo(_partScroll);
        make.right.equalTo(@0);
    }];
}


@end
